<script setup>
import { TreeListAPI } from "@/api/mold/requisition";

const { proxy } = getCurrentInstance();

const emit = defineEmits(["change", "update:modelValue"]);
const props = defineProps({
  disabled: { type: Boolean, default: false },
  modelValue: {
    type: String,
    default: "",
  },
});

const options = ref([]);

const data = ref("");

/**
 * 安装地点
 */
const treeLisDdl = async () => {
  const { data: res } = await TreeListAPI();

  options.value = res;
};
// treeLisDdl()

watchEffect(() => {
  data.value = props.modelValue;
  treeLisDdl();
});

const change = (val) => {
  emit("update:modelValue", val);
  emit("change", val);
};
</script>

<template>
  <el-tree-select
    v-model="data"
    :props="{
      children: 'children',
      label: 'regionName',
      value: 'id',
    }"
    :data="options"
    clearable
    :disabled="props.disabled"
    :render-after-expand="false"
    @change="change"
    style="width: 240px"
  />
</template>
<style scoped lang="scss"></style>
